from flask import Flask
from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy
from config import config_dict
from info.modules.news.views import api

db = SQLAlchemy()


def create_app(config_name):
    app = Flask(__name__)

    app.config.from_object(config_dict[config_name])

    # 注册蓝图对象api
    app.register_blueprint(api)

    db.init_app(app)

    Migrate(app, db)

    return app
